home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / DREGMEM.INC < prev    next >
Text File  |  1993-05-04  |  5KB  |  204 lines

  1. ;Display Regs/memory procedure by D. E. Johnson
  2. ;  MICON Systems, Inc.   or  Computer Science Dept.
  3. ;  RT. 3, Box 163D           University of Wis.
  4. ;  Menomonie, WI 54751       Eau Claire, WI 54701
  5. ;This program may be used without obligation,
  6. ;  but NO PART OF IT MAY BE SOLD.
  7. ;** Useage: Include the following in your code **
  8. ;    CALL DRM    ;To display regs and/or mem
  9. ;    INCLUDE 'DREGMEM.INC' ;Once, at end of program
  10. ;May be assembled alone to see where DOS loads .COMs
  11. ;System (normal) or local stack used (see next line)
  12. lstk equ 0;40 ;0 for system stack, # for local stack
  13. ; (device drivers require local stack of 40)
  14. ;All registers are restored before exit
  15. drm    proc    near    ;from DOS or included
  16.  if $ > 256
  17.      expand-    ;don't list macro
  18.  else
  19.      expand+    ;do list macro
  20.  endif
  21.      list-    ;don't list macro definition
  22. xpand    macro        ;make all symbols local
  23.     cs:
  24.     mov    ssp,sp
  25.     cs:
  26.     push    ssp    ;put regs on stack
  27.     push    ss
  28.     pushf        ;save regs
  29.     push    bp
  30.     push    ds
  31.     push    si
  32.     push    ax
  33.     push    bx
  34.     push    cx
  35.     push    dx    ;fills stack for driver use
  36.  if lstk
  37.     mov    bx,ss    ;save old segment
  38.     mov    cx,cs
  39.     mov    ax,offset h ;past new stack
  40.     cli        ;no breaks
  41.     mov    ss,cx    ;new stack
  42.     xchg    ax,sp
  43.     sti
  44.     push    bx    ;old SS
  45.     push    ax    ;& SP on stack top
  46.     mov    bx,4    ;# words for first display
  47.  endif
  48.     push    di    ;push for initial display
  49.     push    es
  50.     mov    ax,offset drm
  51.     push    ax    ;address of this procedure
  52.     push    cs
  53.     push    cs
  54.     pop    ds    ;to current segment
  55.     mov    dx,offset h
  56.     mov    ah,9
  57.     int    21h    ;display header
  58.  ifn lstk
  59.     mov    si,sp    ;source address
  60.     mov    bx,15    ;# of words to display
  61.  endif
  62.     MOV     cX,3a04h ;colon & # to rotate
  63.  if lstk
  64.     pop    ax    ;word from stack
  65.     call    wdis    ;display load params
  66.     dec    bx
  67.     jne near $-5    ;til all 4 done
  68.     lds    si,h-4    ;old stack
  69.     mov    bl,11    ;# words left
  70.     lodsw
  71.     call    wdis    ;display regs
  72.     dec    bx
  73. ;note: displacements used because of WASM bug
  74. ;indicating "UNUSED SYMBOLS" if defined first
  75.     jne near $-5    ;til done
  76.     push    cs
  77.     pop    ds    ;DS = CS
  78.  else
  79.     seg    ss    ;data on stack
  80.     lodsw        ;Word to display
  81.     call    wdis    ;display load params
  82.     dec    bx
  83.     jne near $-6    ;til all 15 done
  84.     add    sp,8    ;remove some regs
  85.  endif
  86.     mov    dx,offset h2
  87. ;print message (WASM bug prevents lebel)
  88.     push    ds    ;message print
  89.     push    cs
  90.     pop    ds
  91.     mov    ah,9
  92.     int    21h    ;display header
  93.     pop    ds
  94.     xor    bp,bp    ;default offset
  95.     jmps    dnxt+4
  96. dnxt    lodsw        ;Next memory word
  97.     call    wdis
  98.     xor    si,si    ;addr accumulated
  99.     xor    ax,ax
  100.     shl    si,cl    ;Accumulate addr
  101.     or    si,ax    ;lsw of address
  102.     mov    ah,7
  103.     int    21h    ;get char into AL
  104.     call    dchar    ;display it
  105.     MOV     AH,0
  106.     cmp    al,'+'    ;process input
  107.     je    next
  108.     cmp    al,10
  109.     je    next    ;on cr-lf also
  110.     cmp    al,'-'
  111.     je    prev
  112.     cmp    al,':'
  113.     je    sets    ;set seg
  114.     cmp    al,'?'    ;Help?
  115.     je    hlp
  116.     CMP     AL,'9'
  117.     JLE     EDIG    ;IF VALID DECIMAL
  118.     DEC     AX      ;'A'=64,'a'=96
  119.     OR      AL,20H  ;A-F = 96-101
  120.     ADD     AL,26   ;>F SETS SF
  121.     JS      stop
  122.     SUB     AL,64   ;A-F = 58-63
  123. EDIG    SUB     AL,'0'  ;AX=BINARY VAL
  124.     Jns     dnxt+8   ;MORE DIGITS
  125.     jmps    dnxt    ;New input
  126. sets    mov    ds,si    ;ds:si = addr of data
  127.     xor    bp,bp    ;offset = 0
  128.     jmps    dnxt+4    ;initialize offset
  129. prev    sub    bp,4    ;display previous word
  130. next    mov    si,bp    ;display next word
  131.     mov    ax,si
  132.     mov    ch,'/'    ;char following offset
  133.     call    wdis+2    ;addr
  134.     jmps    dnxt
  135. hlp    mov    dx,offset help
  136.     jmps    dnxt-12 ;to message display
  137. stop    ;restore everything & exit
  138.  if lstk
  139.     pop    ax    ;SP to restore
  140.     cli        ;restored later
  141.     pop    ss
  142.     xchg    ax,sp    ;stack restored
  143.  endif
  144.     pop    dx    ;restore regs modified
  145.     pop    cx
  146.     pop    bx
  147.     pop    ax
  148.     pop    si
  149.     pop    ds
  150.     pop    bp
  151.     popf
  152.     pop    ss    ;doesn't change
  153.     pop    sp    ;restore original SP
  154.     ret
  155.   endp    ;drm
  156. wdis    proc    near    ;display word & trailer
  157.     mov    bp,si    ;save for +/-
  158.     mov    dh,cl    ;4
  159.     rol    ax,cl
  160.     push    ax
  161.     and    al,15    ;4 bits
  162.     ADD     AL,'0'  ;GENERATE DIGIT
  163.     CMP     AL,'9'
  164.     JLE     NORM    ;0-9
  165.     ADD     AL,7    ;A-F
  166. NORM    CALL    DCHAR    ;display digit
  167.     pop    ax
  168.     dec    dh
  169.     jne    wdis+4    ;next digit
  170.     mov    al,ch    ;terminating char
  171.     mov    ch,' '    ;"fall" into display
  172. DCHAR    ;proc    near    ;display single char in AL
  173.     mov    dl,al
  174.     mov    ah,2    ;char display command
  175.     int    21h    ;do display at cursor
  176.     cmp    dl,13
  177.     mov    dl,10
  178.     je near $-7
  179.     ret
  180.     endp ;DCHAR & WDIS
  181. help db 13,10,    ;This starts the data area
  182.   db 'D. Johnson memory examiner:  "+"/"Ret" = n'
  183.   db 'ext word, "-" = previous word'
  184.   db 13,10,' (e. g. - - from 0 OFFSET in CS when'
  185.   db ' first started)',13,10,'4-digit addresses '
  186.   db 'have leading zeros assumed (trailing ":" se'
  187.   db 'ts new segment)',13,10
  188.   db '   <"0"= end address input (e. g. - "/")  '
  189.   db '    >"F"= exit (e. g. - "q")',13,10,'$'
  190.  if lstk ;stack may expand into help message
  191.     ds    lstk    ;room for stack
  192.  endif ;40 bytes prevents garbled '?' message
  193. ssp dw    0 ;entry SP & 1st local stack
  194. h db 13,10,' DRM Addr  ES   DI   DX   CX   BX   '
  195.   db 'AX   SI   DS   BP Flags  SS   SP  RA ?=Help'
  196.   db 13,10,'$'
  197. h2 db 'Init', 13,10,'$'
  198.  endm ;xpand
  199.  
  200.  if $ = 256
  201.     list+
  202.  endif
  203.  xpand     ;expand macro (symbols local)
  204.